/**
 * 
 */
package combinatorics;

/**
 * @author Michael
 * Given n sets of choices: (1,2,3), (2,3,4), (4,5)
 * You pick one element from each set of choices.
 * Generate all possible picking.
 */
public class PrintAllPossiblePicking {

	 
	public static void pick(int[][] choices, int index, int[] picking) {
		if (picking.length == index) {
			for (int i = 0; i < picking.length; ++i) 
				System.out.printf("%d ", picking[i]);
			System.out.println();
		}
		else {
			int x = choices[index].length;
			for (int i = 0; i < x; ++i) {
				picking[index] = choices[index][i];
				pick(choices, index + 1, picking);
			}
		}
	}
	
	


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[][] choices = { { 1, 2, 3 },
			            	{ 2, 3, 4 },
				            { 4, 5 } };
		pick(choices, 0, new int[choices.length]);

	}

	/**
	 * 
	 */
	public PrintAllPossiblePicking() {
		// TODO Auto-generated constructor stub
	}
}
